﻿using System;
using System.Collections.Generic;
using Equation.Enterprise.Framework.Domain.Model;
using Equation.Enterprise.Utilities.DesignByContract;

namespace ENail.Domain.Core
{
    public class Registration : EntityWithTypedId<Int16>
    {
        public virtual Customer Customer { get; set; }
        public Status Status
        {
            get { return (Status) StatusId; }
            set { StatusId = (int) value; }
        }
        public int StatusId { get; set; }
        public DateTime StartTime { get; set; }
        public DateTime EndTime { get; set; }

        public virtual Receipt Receipt { get; set; }

        public virtual NailSalon NailSalon { get; set; }
        public bool IsActive { get; set; }

        public virtual IList<Assignment> Assignments { get; set; }

         public Registration()
        {
            Status = Status.Opened;
            StartTime = DateTime.Now;
            IsActive = true;

            Assignments = new List<Assignment>(); 
        }

        public void AddAssignment(Assignment assignment)
        {
            Check.Require(assignment != null);

            assignment.Registration = this;
            Assignments.Add(assignment);
        }

        public void Close()
        {
            Status = Status.Closed;
            EndTime = DateTime.Now;
        }
    }

    public enum Status
    {
        Opened=1,
        Assigned=2,
        Closed=3
    }
}
